package cn.qm.service;


import cn.qm.dao.PrescriptionBatchDetailMapper;
import cn.qm.pojo.PrescriptionBatchDetail;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
* Created by shang-pc on 2018/5/15.
*/
@RestController
public class PrescriptionBatchDetailClient {
    @Resource
    private PrescriptionBatchDetailMapper detailMapper;
    @RequestMapping(value = "/getPrescriptionBatchDetailById", method = RequestMethod.POST)
    public PrescriptionBatchDetail getPrescriptionBatchDetailById(@RequestParam Long id) throws Exception {
        return detailMapper.getPrescriptionBatchDetailById(id);
    }

    @RequestMapping(value = "/getPrescriptionBatchDetailListByMap", method = RequestMethod.POST)
    public List<PrescriptionBatchDetail> getPrescriptionBatchDetailListByMap(@RequestBody Map<String, Object> param) throws Exception {
        return detailMapper.getPrescriptionBatchDetailListByMap(param);
    }

    @RequestMapping(value = "/getPrescriptionBatchDetailCountByMap", method = RequestMethod.POST)
    public Integer getPrescriptionBatchDetailCountByMap(@RequestBody Map<String, Object> param) throws Exception {
        return detailMapper.getPrescriptionBatchDetailCountByMap(param);
    }

    @RequestMapping(value = "/qmtxAddPrescriptionBatchDetail", method = RequestMethod.POST)
    public Integer qmtxAddPrescriptionBatchDetail(@RequestBody PrescriptionBatchDetail prescriptionBatchDetail) throws Exception {
        prescriptionBatchDetail.setCreatedTime(new Date());
        return detailMapper.insertPrescriptionBatchDetail(prescriptionBatchDetail);
    }

    @RequestMapping(value = "/qmtxModifyPrescriptionBatchDetail", method = RequestMethod.POST)
    public Integer qmtxModifyPrescriptionBatchDetail(@RequestBody PrescriptionBatchDetail prescriptionBatchDetail) throws Exception {
        prescriptionBatchDetail.setUpdatedTime(new Date());
        return detailMapper.updatePrescriptionBatchDetail(prescriptionBatchDetail);
    }

    @RequestMapping(value = "/qmtxDeletePrescriptionBatchDetailById", method = RequestMethod.POST)
    public Integer qmtxDeletePrescriptionBatchDetailById(@RequestParam Long id) throws Exception {
        return detailMapper.deletePrescriptionBatchDetailById(id);
    }

    @RequestMapping(value = "/queryPrescriptionBatchDetailPageByMap", method = RequestMethod.POST)
    public Page<PrescriptionBatchDetail> queryPrescriptionBatchDetailPageByMap(@RequestBody Map<String, Object> param, Integer pageNo, Integer pageSize) throws Exception {
        return null;
    }
}
